<%@ page import="java.sql.*" %>
<%@ page import="java.util.List" %>

<%--
  Created by IntelliJ IDEA.
  User: 698
  Date: 2025/4/15
  Time: 下午3:53
  To change this template use File | Settings | File Templates.
--%>
<%
    String dbuser="root";
    String dbpwd="669988";
    String dburl="jdbc:mysql://localhost:3306/bm";
    String driver="com.mysql.jdbc.Driver";
    Class.forName(driver);
    Connection conn= DriverManager.getConnection(dburl,dbuser,dbpwd);

%>
<%!
    int dosave(String sql, List<String> paramsList){
        String dbuser="root";
        String dbpwd="669988";
        String dburl="jdbc:mysql://localhost:3306/bm";
        String driver="com.mysql.jdbc.Driver";
        Connection conn=null;
        PreparedStatement pstmt=null;
        int count=0;
        try {
            Class.forName(driver);
            conn= DriverManager.getConnection(dburl,dbuser,dbpwd);
            pstmt=conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            for(int i=0;i<paramsList.size();i++){
                pstmt.setObject(i+1,paramsList.get(i));
            }
            count=pstmt.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            try {
                pstmt.close();
                conn.close();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            return count;
        }
    }
%>